package leetcode.greedy;

import java.util.Arrays;

/**
 * @author mazouri
 * @create 2021-09-21 9:48
 */
public class _455_findContentChildren {
    public int findContentChildren(int[] g, int[] s) {
        if (s == null || s.length == 0) return 0;

        Arrays.sort(g);
        Arrays.sort(s);
        int count = 0;
        int gIndex = 0;
        for (int i = 0; i < s.length; i++) {
            if (gIndex < g.length && s[i] >= g[gIndex]) {
                gIndex++;
                count++;
            }
        }
        return count;
    }

    public static void main(String[] args) {
        System.out.println(new _455_findContentChildren().findContentChildren(new int[]{1, 2}, new int[]{1, 2, 3}));
    }
}
